home *** CD-ROM | disk | FTP | other *** search
/ CDUTIL 13 / CDUTIL #13 Julio 1995.iso / windows / acadwin / ads / cpp / mfcads / mfcblank / mfcblank.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-08  |  4.0 KB  |  140 lines

  1. /* 
  2.     MFCBLANK.CPP -
  3.     
  4.     This file:
  5.  
  6.         Implements a VERY simple MFC ADS program.  
  7.  
  8.         (xload "MFCBLANK") to load the app.
  9.  
  10.         (test) To request service from the app.  The app responds by
  11.                print out "HELLO from MFCADS" message in ACAD text window.
  12.  
  13.     (C) Copyright 1988-1994 by Autodesk, Inc.
  14.  
  15.     This program is copyrighted by Autodesk, Inc. and is  licensed
  16.     to you under the following conditions.  You may not distribute
  17.     or  publish the source code of this program in any form.   You
  18.     may  incorporate this code in object form in derivative  works
  19.     provided  such  derivative  works  are  (i.) are  designed and
  20.     intended  to  work  solely  with  Autodesk, Inc. products, and
  21.     (ii.)  contain  Autodesk's  copyright  notice  "(C)  Copyright
  22.     1988-1994 by Autodesk, Inc."
  23.  
  24.     AUTODESK  PROVIDES THIS PROGRAM "AS IS" AND WITH  ALL  FAULTS.
  25.     AUTODESK  SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF  MER-
  26.     CHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK,  INC.
  27.     DOES  NOT  WARRANT THAT THE OPERATION OF THE PROGRAM  WILL  BE
  28.     UNINTERRUPTED OR ERROR FREE.
  29.  
  30. */
  31. #include <afxwin.h>
  32. #include "adsinc.h"
  33. #include "mfcads.h"
  34. #include "resource.h"
  35.  
  36.  
  37. //-----------------------------------------------------------------------------
  38. struct MYADS_APP : ADS_APP
  39. {
  40.     virtual BOOL    InitInstance();
  41. };
  42.  
  43. //-----------------------------------------------------------------------------
  44. MYADS_APP   myads_app;
  45.  
  46. //-----------------------------------------------------------------------------
  47. static char temp_buf[ 256 ];
  48.  
  49. //-----------------------------------------------------------------------------
  50. extern "C" void test( struct resbuf* )
  51. {
  52.     wsprintf( temp_buf, "HELLO from MFCADS\n" );
  53.     ads_printf( temp_buf );
  54. }
  55.  
  56. //-----------------------------------------------------------------------------
  57. ADS_FUNC_INFO       app_funs[] = 
  58. {
  59. /*                                                                          */
  60. /*      Function                       Type            Name      Message    */
  61. /*                                                                          */
  62.   ADS_FUNC_INFO( ADS_FUNC( test ),   ADS_VOID_FUNC,  "c:test", "Use Test\n")
  63. };
  64.  
  65. //-----------------------------------------------------------------------------
  66. class CMainWindow : public CFrameWnd
  67. {
  68. public:
  69.     CMainWindow();
  70.  
  71.     //{{AFX_MSG( CMainWindow )
  72.     afx_msg void OnPaint();
  73.     afx_msg void OnAbout();
  74.     //}}AFX_MSG
  75.  
  76.     DECLARE_MESSAGE_MAP()
  77. };
  78.  
  79. //-----------------------------------------------------------------------------
  80. CMainWindow::CMainWindow()
  81. {
  82.     LoadFrame(IDR_MAINFRAME);
  83. }
  84.  
  85. //-----------------------------------------------------------------------------
  86. void CMainWindow::OnPaint()
  87. {
  88.     CRect rect;
  89.     GetClientRect(rect);
  90.  
  91.     CPaintDC dc(this);
  92.     dc.SetTextAlign(TA_BASELINE | TA_CENTER);
  93.     dc.SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
  94.     dc.SetBkMode(TRANSPARENT);
  95.     CString s;
  96.     s.LoadString(IDS_HELLO);
  97.     dc.TextOut((rect.right / 2), (rect.bottom / 2), s);
  98. }
  99.  
  100. //-----------------------------------------------------------------------------
  101. void CMainWindow::OnAbout()
  102. {
  103.     CDialog about(IDD_ABOUTBOX);
  104.     about.DoModal();
  105. }
  106.  
  107. BEGIN_MESSAGE_MAP( CMainWindow, CFrameWnd )
  108.     //{{AFX_MSG_MAP( CMainWindow )
  109.     ON_WM_PAINT()
  110.     ON_COMMAND(ID_APP_ABOUT, OnAbout)
  111.     //}}AFX_MSG_MAP
  112. END_MESSAGE_MAP()
  113.  
  114. //-----------------------------------------------------------------------------
  115. BOOL    MYADS_APP::InitInstance()
  116. {
  117.     TRACE0("CTheApp::InitInstance\n");
  118.  
  119.     if ( ADS_APP::InitInstance() != TRUE )
  120.     {
  121.         return FALSE;
  122.     }
  123.     for ( int i = 0; i < ARRAY_SIZE( app_funs ); i++ )
  124.     {
  125.         if ( InsertExternFunc( app_funs[i] ) == -1 )
  126.         {
  127.             return FALSE;
  128.         }
  129.     }
  130. #if 0   // VC2...
  131.     Enable3dControls(); // use 3d controls in dialogs
  132. #endif
  133.     m_pMainWnd = new CMainWindow;
  134.     m_pMainWnd->ShowWindow(m_nCmdShow);
  135.     m_pMainWnd->UpdateWindow();
  136.  
  137.     return TRUE;
  138. }
  139.  
  140.